package cn.gogoyc.org.basic.listeneer;

import cn.gogoyc.system.service.IPermissionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;
import javax.servlet.annotation.WebListener;

/**
 * Servlet监听器
 * @author Yang
 * @date 2023/2/14 14:34
 */
@WebListener
public class PermissionScanInitListener implements ServletContextListener {
    @Autowired
    private IPermissionService permissionService;

    @Override
    public void contextInitialized(ServletContextEvent sce) {
        new Thread(new Runnable() {//不用主线程去执行，用一个新的线程去执行
            @Override
            public void run() {
                permissionService.scanPermissions();
            }
        }).start();
    }
}
